package demo7;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Person {
    private String name;

    public Person() {
        System.out.println("1:Person的构造方法被调用了");
    }

    public String getName() {
        return name;
    }

    @Value("C.C.")
    public void setName(String name) {
        System.out.println("2:Person的set方法被调用了，初始化name属性");
        this.name = name;
    }

    @PostConstruct
    public void postContrust() {
        System.out.println("3:Person的postContrust方法被调用了");
    }

    public void play() {
        System.out.println("4：正常的方法调用了");
        System.out.println(name + "在玩弄着谁");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("Destroy方5：Person的pre法被调用了");
    }
}
